package com.jt.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class SpringAOP {
    @Pointcut("bean(userServiceImpl)")
    public void Pointcut(){

    }

    @Before("Pointcut()")
    public void before(){
        System.out.println("我是前置任务");
    }

    @AfterThrowing("Pointcut()")
    public void afterThrowing(){
        System.out.println("任务失败");
    }

    @AfterReturning("Pointcut()")
    public void afterReturning(){
        System.out.println("我开始分钱了");
    }

    @After("Pointcut()")
    public void after(){
        System.out.println("任务结束");
    }

    @Around("Pointcut()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("准备前置任务！");
        Object result = joinPoint.proceed();
        System.out.println("任务完成");
        return  result;
    }
}
